﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lib
{
    public class DateUtil
    {
        /// <summary>
        /// 获取当前日期:170406
        /// </summary>
        public static String getCurrentDateYYMMDD()
        {
            return DateTime.Now.ToString("yyMMdd");
        }

        /// <summary>
        /// 获取日期:20170406
        /// </summary>
        public static String getDateYYYYMMDD(DateTime dt)
        {
            return dt.ToString("yyyyMMdd");
        }

        /// <summary>
        /// 日期字符串转DateTime
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public static DateTime getDateTime(String date)
        {
            return Convert.ToDateTime(date);
        }

        /// <summary>
        /// 给指定日期添加天数
        /// </summary>
        /// <param name="datetime"></param>
        /// <param name="days"></param>
        /// <returns></returns>
        public static DateTime dateTimeAddDays(String datetime, String days)
        {
            return getDateTime(datetime).AddDays(int.Parse(days));
        }
    }
}
